<h1>图书列表</h1>
<%if check_admin%>
<%= link_to '添加新书', :action => 'new' %>
<%end%>
<table class="listing">
  <tr>  
  <thead>
    <th >立通编号</th>
    <th >书名</th>
    <th >价格</th>
    <th >出版社</th>
    <th >状态</th>
    <%if check_admin%>
    <th width="8%">编辑</th>
    <th width="8%">删除</th>
    <%end%>
  </thead>
  </tr>
<% @books.each_with_index do |book,i| %>
  <tr class="line<%=i%2%>">
    <td><%=h book.lt_code %></td>
    <td><%=link_to book.book_name, {:action => 'show' ,:id => book },:title=>"图书详细信息" ,:rel=>"gb_pageset[books]"%></td>
    <td><%=h book.price %>¥</td>
    <td><%=h book.publish.publish_name %></td>
    <td><%=h book.book_status.status %></td>    
    <%if check_admin%>
        <td ><%= link_to image_tag("edit.gif",:size => "16x16"), :action => 'edit', :id => book %></td>
        <%if(book.book_status.id==1)%>
        <td ><%= link_to image_tag("delete.gif",:size => "16x16"), { :action => 'destroy', :id => book}, :confirm => "确认删除?\n[#{book.book_name}]", :post => true %></td>
        <%else%>
        <td ><%= image_tag("no_del.gif",:size => "16x16",:alt=>"借出中的图书不能删除")%></td>
        <%end%>
    <%end%>
  </tr>
<% end %>
</table>

<%=render :partial => 'shared/paginate' , :object => @books_pages%>
<br />